<div class="btn-group" style="margin-right: 5px" data-toggle="buttons">
    <label class="btn btn-sm btn-dropbox {{ $btn_class }} {{ $expand ? 'active' : '' }}" title="{{ trans('admin.filter') }}">
        <input type="checkbox"><i class="fa fa-filter"></i><span class="hidden-xs">&nbsp;&nbsp;{{ trans('admin.filter') }}</span>
    </label>

    @if($scopes->isNotEmpty())
        <button type="button" class="btn btn-sm btn-dropbox @if (!$label)dropdown-toggle @endif" data-toggle="dropdown">
            <span>{{ $label }}</span>
            <span class="caret"></span>
            <span class="sr-only">Toggle Dropdown</span>
        </button>
        @if ($label)
            <a href="{{$cancel}}" class="btn btn-sm btn-danger dropdown-toggle"><i class="fa fa-times"></i></a>
        @endif
        <ul class="dropdown-menu" role="menu">
            @foreach($scopes as $scope)
                {!! $scope->render() !!}
            @endforeach
            <li role="separator" class="divider"></li>
            <li><a href="{{ $cancel }}">{{ trans('admin.cancel') }}</a></li>
        </ul>
    @endif
</div>

<script>
    var $btn = $('.{{ $btn_class }}');
    var $filter = $('#{{ $filter_id }}');

    $btn.unbind('click').click(function (e) {
        if ($filter.is(':visible')) {
            $filter.addClass('hide');
        } else {
            $filter.removeClass('hide');
        }
    });
</script>
